<template>
	<custom-form-layout>
		<custom-form-item-card label="超时备注说明" required>
			<fui-textarea v-model="formData.timeOutRemark" placeholder="你可以详细描述超时原因，这将是考核时的重要依据"></fui-textarea>
		</custom-form-item-card>

		<template #footer>
			<fui-row class="footer" id="footer">
				<fui-col :span="11">
					<fui-button background="#F2F3FF" color="#0052D9" @click="cancel">
						取消
					</fui-button>


				</fui-col>
				<fui-col :span="11" :offset="2">
					<fui-button background="#0052D9" color="#fff" @click="submit">
						提交
					</fui-button>
				</fui-col>


			</fui-row>
		</template>
	</custom-form-layout>


</template>

<script>
	import form from '@/components/firstui/fui-validator/fui-validator'
	import {
		WorkOrderApi
	} from '../../api/workOrder';
	import {
		SubPages
	} from '../../config/router-config';
	export default {
		data() {
			return {
				formData: {
					id: null,
					timeOutRemark: ''
				}
			};
		},
		onLoad(options) {
			this.formData.id = options.id
		},
		methods: {
			cancel() {
				uni.navigateBack()
			},
			async submit() {
				let res = form.validator(this.formData, [{
					name: "timeOutRemark",
					rule: ["required"],
					msg: ["请输入说明"]
				}]);
				if (res.isPassed) {
					try {
						await WorkOrderApi.timeoutRemark(this.formData)
						uni.showModal({
							title: '提示',
							content: '提交成功!',
							showCancel: false,
							success() {
								// uni.navigateBack()
								uni.redirectTo({
									url: SubPages.MY_WORK_ORDER.router
								})
							}
						})
					} catch (err) {
						console.log(err);
						// this.fui.toast(err)
					}
				} else {
					this.fui.toast(res.errorMsg)
				}
			}
		},


	}
</script>

<style lang="scss">

</style>